//
//  ThongTinViewController.m
//  NhomTuan
//
//  Created by HOCVIEN on 1/27/15.
//  Copyright (c) 2015 t3h. All rights reserved.
//

#import "ThongTinViewController.h"
#import "ThongTinCustomView.h"
#import "Member.h"
@interface ThongTinViewController ()

@end

@implementation ThongTinViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}
- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleLightContent;
}
- (void)viewWillAppear:(BOOL)animated {
    self.scrollThongTin.delegate = self;
    self.automaticallyAdjustsScrollViewInsets = NO;
    [self.navigationController.navigationBar setBarTintColor:[AppUtils greenColor]];
    [self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];
    UIImage *image = [UIImage imageNamed:@"img_logo.png"];
    UIImageView *titleImg = [[UIImageView alloc] initWithImage:image];
    [self.navigationController.navigationBar.topItem setTitleView:titleImg];

    float scrollViewWidth = 0;
    //int count = [AppManager defaultmanager].singerList.count;
    int count = [AppManager defaultmanager].members.count;
    for (int i = 0; i < count; i++) {
        ThongTinCustomView *view = [[ThongTinCustomView alloc] init];

        Member *member = [[Member alloc] initMemberInArray:[AppManager defaultmanager].members atIndex:i];
        view.imgAvatar.image = member.avatar;
        
        
        view.lblName.text = member.name;

        //        Singer *singer = [[Singer alloc] initSingerInArray:[AppManager defaultmanager].singerList atIndex:i];
        //        view.imgAvatar.image = singer.avatar;
        //        view.lblName.text = singer.name;

        CGRect viewFrame = view.frame;
        viewFrame.origin.y = 0;
        viewFrame.origin.x = view.frame.size.width * i;
        scrollViewWidth = viewFrame.origin.x + view.frame.size.width;
        view.frame = viewFrame;
        [self.scrollThongTin addSubview:view];
    }

    [self.scrollThongTin setContentSize:CGSizeMake(scrollViewWidth, self.scrollThongTin.frame.size.height)];
    [self.scrollThongTin setPagingEnabled:true];
    self.pageViewThongTin.numberOfPages = count;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    float page = self.scrollThongTin.contentOffset.x / self.scrollThongTin.frame.size.width;
    self.pageViewThongTin.currentPage = page;
}

@end
